//
//  CANoticeTableViewCell.m
//  LNH
//
//  Created by twentylx on 2018/2/8.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CANoticeTableViewCell.h"

@implementation CANoticeTableViewCell

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview:self.titleLabel];
        [self addSubview:self.newLabel];
        [self addSubview:self.dateLabel];
        [self addSubview:self.readLabel];
        
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(20);
            make.top.equalTo(self).offset(20);
        }];
        
        [_newLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.titleLabel);
            make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
            make.width.mas_equalTo(50);
            make.height.mas_equalTo(20);
        }];
        
        [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.newLabel.mas_right).offset(20);
            make.centerY.equalTo(self.newLabel);
        }];
        
        [_readLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-10);
            make.centerY.equalTo(self.newLabel);
        }];
    }
    return self;
}

#pragma mark get & set
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"培训预告：APP功能基础";
        _titleLabel.font = [UIFont systemFontOfSize:16];
    }
    return _titleLabel;
}

- (UILabel *)newLabel {
    if (!_newLabel) {
        _newLabel = [UILabel new];
        _newLabel.text = @"NEW";
        _newLabel.font = [UIFont systemFontOfSize:14];
        _newLabel.textColor = RGBCOLOR(231, 56, 40);
        _newLabel.layer.borderWidth = 1;
        _newLabel.layer.borderColor = [RGBCOLOR(242, 147, 139) CGColor];
        _newLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _newLabel;
}

- (UILabel *)dateLabel {
    if (!_dateLabel) {
        _dateLabel = [UILabel new];
        _dateLabel.text = @"2018-2-3 18:00:00";
        _dateLabel.font = [UIFont systemFontOfSize:14];
        _dateLabel.textColor = RGBCOLOR(158, 158, 158);
    }
    return _dateLabel;
}

- (UILabel *)readLabel {
    if (!_readLabel) {
        _readLabel = [UILabel new];
        _readLabel.text = @"103人已读";
        _readLabel.font = [UIFont systemFontOfSize:14];
        _readLabel.textColor = RGBCOLOR(158, 158, 158);
        _readLabel.textAlignment = NSTextAlignmentRight;
    }
    return _readLabel;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
